import request from '@/utils/request'

export function fetchDepartmentList(data) {
  return request({
    url: '/cloud-system/getDepartmentList',
    method: 'post',
    data
  })
}

export function fetchDepartmentOne(data) {
  return request({
    url: '/cloud-system/getOneDepartmentDetail',
    method: 'post',
    data
  })
}

export function createDepartment(data) {
  return request({
    url: '/cloud-system/createOneDepartment',
    method: 'post',
    data
  })
}

export function updateDepartment(data) {
  return request({
    url: '/cloud-system/updateOneDepartment',
    method: 'post',
    data
  })
}

export function deleteDepartment(data) {
  return request({
    url: '/cloud-system/deleteOneDepartment',
    method: 'post',
    data
  })
}

export function lockDepartment(data) {
  return request({
    url: '/cloud-system/lockOneDepartment',
    method: 'post',
    data
  })
}

export function unlockDepartment(data) {
  return request({
    url: '/cloud-system/unlockOneDepartment',
    method: 'post',
    data
  })
}

/**
 * 移动节点顺序
 * @param {*} moveDepartmentID 被移动的节点ID
 * @param {*} categoryID 移动到目的前后的节点ID
 * @param {*} moveSide 移动位置 1 代码移动到categoryID 之前， 2代表移动到categoryID之后
 * @param {*} token token身份认证
 * @returns
 */
export function moveOneDepartment(moveDepartmentID, categoryID, moveSide, token) {
  return request.post('/cloud-system/moveOneDepartment', {
    moveDepartmentID,
    categoryID,
    moveSide,
    token
  })
}
